package org.example.web;

import org.example.damai.entiy.User;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

@RestController
@RequestMapping("feign")
public class FeginDemoDo {

    @RequestMapping("hello")
    Mono<String> hello(String name) {
        return Mono.just("Hello " + name);
    }

    @RequestMapping("add")
    Mono<Integer> add(int a, int b){
        return Mono.just(a+b);
    }

    @RequestMapping("sub/{a}/{b}")
    Mono<Integer> sub(@PathVariable("a") int a,
                      @PathVariable int b){
        return Mono.just(a-b);
    }

    @RequestMapping("setUser")
    Mono<User> setUser(String newName,
                       int newAge,
                       @RequestBody User user){
        user.setAge(user.getAge() + newAge);
       user.setName(newName);
        return Mono.just(user);
    }

}
